<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>按钮</button>
    <p></p>
    <script>
      let btn = document.querySelector("button");
      let p = document.querySelector("p");
      let i=5;

      btn.addEventListener("click", function (e) {
         setInterval(function () {
           if(i==0){
            //  location.assign("https://www.baidu.com/")
            location.href="https://www.baidu.com/"
           }else{
              i--;
             p.innerHTML=`倒计时${i}`
           
           }
         },1000)
      });
    </script>
  </body>
</html>
